package org.qb.mapreduce.mapJoinDemo;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import javax.xml.soap.Text;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class MapJoinDriver {
    public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException, ClassNotFoundException {

        Job job = Job.getInstance(new Configuration());

        job.setJarByClass(MapJoinDriver.class);

        job.setMapperClass(MapJoinMapper.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);

        //将其设置为0，不需要走reducer
        job.setNumReduceTasks(0);

        //设置缓存
        job.addCacheFile(new URI("file:///D:/hadoopCache/inputTable/pd.txt"));

        //设置输出路径
        FileInputFormat.setInputPaths(job, new Path("D:\\big data\\hadoop3.X\\资料\\11_input\\inputTable2"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\big data\\hadoop3.X\\output\\mapJoinDemo1"));

        boolean b = job.waitForCompletion(true);
        System.exit(b ? 0 : 1);

    }
}
